//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<editor.h>
///	@path	~/src/editor/
///	@date	2008/05/16
///	@desc	Editor declaration.

#pragma once

#define _FULLAPI
#include "config/config.h"

#include "resource/resource.h"

//#include "winuser.h"

// using WTL as UI framework
#include <atlbase.h>
#include <atlwin.h>
#include "wtl/atlapp.h"
#include "wtl/atlframe.h"
#include "wtl/atlctrls.h"
#include "wtl/atldlgs.h"
#include "wtl/atlmisc.h"

// Application Module
__declspec(selectany) CAppModule __AppModule;

#pragma warning( disable : 4238 )

// GDI+
#include <GdiPlus.h>

// Extra Message
// timer subscriber -			(WM_XS_TIMER , (WPARAM)subscriber , (LPARAM) dwTime )
#define	WM_XS_TIMER				(WM_USER + 101)
// edit control caret flash -	(WM_XS_EDITCARET , 0 , 0 )
#define WM_XS_EDITCARET			(WM_USER + 102)
// track pop up menu -			(WM_XS_TRACKPOPUP , (WPARAM)HMENU , MAKELPARAM( pos.x , pos.y ) )
#define	WM_XS_TRACKPOPUP		(WM_USER + 103)
// update component -			(WM_XS_UPDATECOMP , (WPARAM)comp , 0 )
#define	WM_XS_UPDATECOMP		(WM_USER + 104)
// update XLayer -				(WM_XS_UPDATELAYER , 0 , 0 )
#define	WM_XS_UPDATELAYER		(WM_USER + 105)
// active XPanel -				(WM_XS_ACTIVEPANEL , (WPARAM)HWND , 0 )
#define	WM_XS_ACTIVEPANEL		(WM_USER + 106)
// parent menu change			(WM_XS_PARENTMENUCHANGE , 0 , 0 ) - return TRUE to indicate change menu
#define	WM_XS_PARENTMENUCHANGE	(WM_USER + 107)
// workspace menu				(WM_XS_WORKSPACEMENU , (WPARAM)track , (LPARAM)xmenu )
#define	WM_XS_WORKSPACEMENU		(WM_USER + 108)

// Standard Timer
// ticking timer
#define	TIMER_TICK				(1000)

static int GetEncoderClsid( const WCHAR* format , CLSID * pClsid )
{
	UINT num = 0;
	UINT size = 0;
	Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL; 
	Gdiplus::GetImageEncodersSize(&num, &size); 
	if( size == 0) 
		return -1; 
	pImageCodecInfo = (Gdiplus::ImageCodecInfo*)(malloc(size)); 
	if(pImageCodecInfo == NULL) 
		return -1;
	Gdiplus::GetImageEncoders(num, size, pImageCodecInfo); 
	for(UINT j = 0; j < num; ++j) 
	{ 
		if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 ) 
		{ 
			*pClsid = pImageCodecInfo[j].Clsid; 
			free(pImageCodecInfo); 
			return j;
		} 
	} 
	free(pImageCodecInfo); 
	return -1;
}

inline bool IsVista()
{
	OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) };
	BOOL bRet = ::GetVersionEx(&ovi);
	return ((bRet != FALSE) && (ovi.dwMajorVersion >= 6));
}
